package com.jdbctable;

import com.jdbctest.numbertwo.JDBCUtils;

import java.sql.Connection;
import java.sql.Statement;

/**
 * 操作数据库表
 */
//DDL
public class TableUtils {

    /**
     * 根据传入的DDL数据库语句创建表或删除
     *
     * @param createTableSQL
     */
    public static void createTable(String createTableSQL) {
        Connection connection = null;
        Statement statement = null;
        try {
            System.out.println("表操作开始");
            connection = JDBCUtils.getConnection();

            statement = connection.createStatement();
            statement.executeUpdate(createTableSQL);
            System.out.println("表操作成功!");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.closeResource(connection, statement);
        }
    }



}
